package top.frsf.envir;

import top.frsf.GameObject;
import top.frsf.GamePanel;

import java.awt.*;

/**
 * @BelongsProject: TankWar1
 * @BelongsPackage: top.frsf.envir
 * @Author: FRSF
 * @CreateTime: 2022-09-04  18:10
 * @Description: 爆炸特效类
 * @Version: 1.0
 */
public class Blast extends GameObject {
    // 爆炸图集
    static Image[] imgs = new Image[7];
    int play = 0;

    static {
        for (int i = 0; i < 7; i++) {
            imgs[i] = Toolkit.getDefaultToolkit().
                    getImage("src/main/resources/blast/boom" + (i + 1) + ".png");
        }
    }

    public Blast(String img, int x, int y, GamePanel gamePanel) {
        super(img, x, y, gamePanel);
    }

    @Override
    public void paintSelf(Graphics g) {
        // 连续播放爆炸图片, bug: 第一次爆炸不显示
/*        while (play<7) {
            g.drawImage(imgs[play], x, y, null);
            play++;
        }*/
        if (play < 7) {
            g.drawImage(imgs[0], x, y, null);
            g.drawImage(imgs[1], x, y, null);
            g.drawImage(imgs[2], x, y, null);
            g.drawImage(imgs[3], x, y, null);
            g.drawImage(imgs[4], x, y, null);
            g.drawImage(imgs[5], x, y, null);
            g.drawImage(imgs[6], x, y, null);
            play++;
        }
    }

    @Override
    public Rectangle getRec() {
        return null;
    }
}
